<script type="text/javascript" >
    stFacebookToolbox.loadMenuCallbackFunction= function(){
        jQuery('#side-nav .left_menu').html('sdfsdfsd');
        jQuery('#side-nav').fadeIn();
    }

</script>
<style>

</style>

<div class="w100p bgl">
    <div class="w100p bgr p5b">
        <ul class="menu_right">
                      <li >
                           <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('gallery_app');" id="form_app">Pictures</a>
                    </li>
                    <li>
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('gallery_setting');" id="fan_count">Settings</a>
                    </li>
                    <li  class="current">
                          <a href="javascript:void(0);" onclick="stFacebookToolboxcustom.loadPage('gallery_album');" id="fan_count">Albums</a>
                    </li>
          </ul>

        <ul class="postcardAction" style="margin-left: 10px;">
                <li>
                    <a class="button add-new-h2 anchor" onclick="add_album();">
                        Add new album
                    </a>
                </li>
            </ul>
        <div class="upload_field" style="display:none;padding-left:13px;">
                <form method="post" action="<?php echo admin_url('/admin.php?page=' . $config['plugin_name'] . '&action=' . $current_action) ?>" style="display: block;" id="uploadObject2" class="stform">
                    <ul>
                        <li>
                            <label>Name:</label>
                            <div class="required">
                                <input type="text" name="data[name]" id="name" class="required"  />
                            </div>
                                <input type="hidden" name="data[id]" id="id"  />
                            <br clear="all">
                        </li>
                        <li>
                            <label>Facebook page:</label>
                            <div class="">
<!--                                <input type="text" name="data[facebook_id]" id="facebook_id" class="required"  />-->
                                <select name="data[facebook_id]" id="facebook_id" class="">
                                    <option value="">Not assigned</option>
                                    <?php foreach($page as $pa):?>
                                    <option value="<?php $pa->pageid;?>"><?php echo $pa->pagename;?></option>
                                    <?php endforeach;?>
                                </select>
                            </div>
                              <br clear="all">
                        </li>
                        <li>
                            <input type="submit" value="Submit">
                            <input type="button" onclick="jQuery('.upload_field').slideUp()" value="Close">
                        </li>
                    </ul>
                    <br style="clear:both;" />
                </form>
            </div>
<table class="widefat" cellspacing="0">
                <thead>
                    <tr>
                        <?php print_column_headers('stFacebookToolbox_stFacebookToolbox'); ?>
                    </tr>
                </thead>

                <tbody>
                <?php
                if (count($results) > 0) {
                    
                    $tr_class = "";
                    foreach ($results as $result) {
                         if( empty($tr_class) || $tr_class == "class='bg_gray2'"){
                            $tr_class = "class='bg_gray1'";
                        }else{
                            $tr_class = "class='bg_gray2'";
                        }
                        echo "<tr id='$result->id' $tr_class >"
                        . "<td>" . $result->id

                        . "</td>"
                        . "<td>" . $result->name
                        . "<div class=\"row-actions short_action\">"
                        . "<div onclick='edit($result->id,\"$result->name\",\"$result->facebook_id\",\"{$model->get_page($result->facebook_id)}\")' style='cursor:pointer;'>Edit | </div>"
                        . "<span class='trash' short_action='delete' id='$result->id' confirm='Are you sure you want to delete this album?' style='cursor:pointer;'>Trash </span>"
                        . "</div>"
                        . "</td>"
                        . "</td>"
                        . "<td><a href='{$model->get_url($result->facebook_id)}?sk=app_111719055546629' target='_blank'>" . $model->get_page($result->facebook_id)
                        . "</a></td>"
                        . "</td>"
                        
                        . "</tr>"
                        ;
                    }
                }
                ?>
                </tbody>
            </table>
            <div class="page_d">
                <?php echo $pagination?>
                <div class="cl"></div>
            </div>
    </div>
</div>